<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>decodebase &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>decodebase
      <small>Function</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 2.8% of total for procedures.">69 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">decodebase</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-xmaxreal">XMAXREAL</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-basein_local">basein_local</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ch~2">ch</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-i~4">i</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ierr">ierr</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ipound">ipound</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-j">j</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-k">k</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-long">long</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-mult">mult</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-out_sign">out_sign</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-string_local">string_local</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-y~2">y</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/decodebase.html#src">decodebase</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public function decodebase(string, basein, out_baseten)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code>decodebase(3f) - [M_strings:BASE] convert whole number string in base
[2-36] to base 10 number
(LICENSE:PD)
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<p>logical function decodebase(string,basein,out10)</p>
<div class="codehilite"><pre><span></span><code>character(len=*),intent(in)  :: string
integer,intent(in)           :: basein
integer,intent(out)          :: out10
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code><span class="nv">Convert</span> <span class="nv">a</span> <span class="nv">numeric</span> <span class="nv">string</span> <span class="nv">representing</span> <span class="nv">a</span> <span class="nv">whole</span> <span class="nv">number</span> <span class="nv">in</span> <span class="nv">base</span> <span class="nv">BASEIN</span>
<span class="nv">to</span> <span class="nv">base</span> <span class="mi">10</span>. <span class="nv">The</span> <span class="nv">function</span> <span class="nv">returns</span> <span class="nv">FALSE</span> <span class="k">if</span> <span class="nv">BASEIN</span> <span class="nv">is</span> <span class="nv">not</span> <span class="nv">in</span> <span class="nv">the</span> <span class="nv">range</span>
[<span class="mi">2</span>..<span class="mi">36</span>] <span class="nv">or</span> <span class="k">if</span> <span class="nv">string</span> <span class="nv">STRING</span> <span class="nv">contains</span> <span class="nv">invalid</span> <span class="nv">characters</span> <span class="nv">in</span> <span class="nv">base</span> <span class="nv">BASEIN</span>
<span class="nv">or</span> <span class="k">if</span> <span class="nb">result</span> <span class="nv">OUT10</span> <span class="nv">is</span> <span class="nv">too</span> <span class="nv">big</span>

<span class="nv">The</span> <span class="nv">letters</span> <span class="nv">A</span>,<span class="nv">B</span>,...,<span class="nv">Z</span> <span class="nv">represent</span> <span class="mi">10</span>,<span class="mi">11</span>,...,<span class="mi">36</span> <span class="nv">in</span> <span class="nv">the</span> <span class="nv">base</span> <span class="o">&gt;</span> <span class="mi">10</span>.
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code>string   input string. It represents a whole number in
         the base specified by BASEIN unless BASEIN is set
         to zero. When BASEIN is zero STRING is assumed to
         be of the form BASE#VALUE where BASE represents
         the function normally provided by BASEIN.
basein   base of input string; either 0 or from 2 to 36.
out10    output value in base 10
</code></pre></div>

<h2 id="example">EXAMPLE</h2>
<p>Sample program:</p>
<div class="codehilite"><pre><span></span><code><span class="nt">program</span> <span class="nt">demo_decodebase</span>
<span class="nt">use</span> <span class="nt">M_strings</span><span class="o">,</span> <span class="nt">only</span> <span class="o">:</span> <span class="nt">codebase</span><span class="o">,</span> <span class="nt">decodebase</span>
<span class="nt">implicit</span> <span class="nt">none</span>
<span class="nt">integer</span>           <span class="o">::</span> <span class="nt">ba</span><span class="o">,</span><span class="nt">bd</span>
<span class="nt">character</span><span class="o">(</span><span class="nt">len</span><span class="o">=</span><span class="nt">40</span><span class="o">)</span> <span class="o">::</span> <span class="nt">x</span><span class="o">,</span><span class="nt">y</span>
<span class="nt">integer</span>           <span class="o">::</span> <span class="nt">r</span>

<span class="nt">print</span> <span class="o">*,</span><span class="s1">&#39; BASE CONVERSION&#39;</span>
<span class="nt">write</span><span class="o">(*,</span><span class="s1">&#39;(&quot;Start   Base (2 to 36): &quot;)&#39;</span><span class="o">,</span><span class="nt">advance</span><span class="o">=</span><span class="s1">&#39;no&#39;</span><span class="o">);</span> <span class="nt">read</span> <span class="o">*,</span> <span class="nt">bd</span>
<span class="nt">write</span><span class="o">(*,</span><span class="s1">&#39;(&quot;Arrival Base (2 to 36): &quot;)&#39;</span><span class="o">,</span><span class="nt">advance</span><span class="o">=</span><span class="s1">&#39;no&#39;</span><span class="o">);</span> <span class="nt">read</span> <span class="o">*,</span> <span class="nt">ba</span>
<span class="nt">INFINITE</span><span class="o">:</span> <span class="nt">do</span>
   <span class="nt">print</span> <span class="o">*,</span><span class="s1">&#39;&#39;</span>
   <span class="nt">write</span><span class="o">(*,</span><span class="s1">&#39;(&quot;Enter number in start base: &quot;)&#39;</span><span class="o">,</span><span class="nt">advance</span><span class="o">=</span><span class="s1">&#39;no&#39;</span><span class="o">);</span> <span class="nt">read</span> <span class="o">*,</span> <span class="nt">x</span>
   <span class="nt">if</span><span class="o">(</span><span class="nt">x</span><span class="p">.</span><span class="nc">eq</span><span class="o">.</span><span class="s1">&#39;0&#39;</span><span class="o">)</span> <span class="nt">exit</span> <span class="nt">INFINITE</span>
   <span class="nt">if</span><span class="o">(</span><span class="nt">decodebase</span><span class="o">(</span><span class="nt">x</span><span class="o">,</span><span class="nt">bd</span><span class="o">,</span><span class="nt">r</span><span class="o">))</span> <span class="nt">then</span>
      <span class="nt">if</span><span class="o">(</span><span class="nt">codebase</span><span class="o">(</span><span class="nt">r</span><span class="o">,</span><span class="nt">ba</span><span class="o">,</span><span class="nt">y</span><span class="o">))</span> <span class="nt">then</span>
        <span class="nt">write</span><span class="o">(*,</span><span class="s1">&#39;(&quot;In base &quot;,I2,&quot;: &quot;,A20)&#39;</span><span class="o">)</span>  <span class="nt">ba</span><span class="o">,</span> <span class="nt">y</span>
      <span class="nt">else</span>
        <span class="nt">print</span> <span class="o">*,</span><span class="s1">&#39;Error in coding number.&#39;</span>
      <span class="nt">endif</span>
   <span class="nt">else</span>
      <span class="nt">print</span> <span class="o">*,</span><span class="s1">&#39;Error in decoding number.&#39;</span>
   <span class="nt">endif</span>
<span class="nt">enddo</span> <span class="nt">INFINITE</span>

<span class="nt">end</span> <span class="nt">program</span> <span class="nt">demo_decodebase</span>
</code></pre></div>

<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban

   Ref.: &quot;Math matiques en Turbo-Pascal by
          M. Ducamp and A. Reverchon (2),
          Eyrolles, Paris, 1988&quot;.

based on a F90 Version By J-P Moreau (www.jpmoreau.fr)
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-string~2"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>string</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-basein"></span>integer,</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>basein</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-out_baseten"></span>integer,</td>
  <td>intent(out)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>out_baseten</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
    
    
    
   <h3>Return Value <small><span class="anchor" id="variable-decodebase"></span>logical
  </small></h3>
    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-xmaxreal">XMAXREAL</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-basein_local">basein_local</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ch~2">ch</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-i~4">i</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ierr">ierr</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-ipound">ipound</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-j">j</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-k">k</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-long">long</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-mult">mult</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-out_sign">out_sign</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-string_local">string_local</a>
      
      <a class="list-group-item" href="../proc/decodebase.html#variable-y~2">y</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/decodebase.html#src">decodebase</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-xmaxreal"></span>real,</td>
  
  <td>public,</td>
  <td>parameter</td><td>::</td>
  <td><strong>XMAXREAL</strong></td><td> =</td><td>real(huge(1))</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-basein_local"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>basein_local</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ch~2"></span>character(len=1),</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ch</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i~4"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ierr"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ierr</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ipound"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ipound</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-j"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>j</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-k"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>k</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-long"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>long</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-mult"></span>real,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>mult</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-out_sign"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>out_sign</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-string_local"></span>character(len=len(string)),</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>string_local</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-y~2"></span>real,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>y</strong></td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="kt">logical </span><span class="k">function </span><span class="n">decodebase</span><span class="p">(</span><span class="n">string</span><span class="p">,</span><span class="n">basein</span><span class="p">,</span><span class="n">out_baseten</span><span class="p">)</span>
<span class="k">implicit none</span>

<span class="c">! ident_73=&quot;@(#)M_strings::decodebase(3f): convert whole number string in base [2-36] to base 10 number&quot;</span>

<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">string</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>           <span class="kd">::</span> <span class="n">basein</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>          <span class="kd">::</span> <span class="n">out_baseten</span>

<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">string</span><span class="p">))</span>   <span class="kd">::</span> <span class="n">string_local</span>
<span class="kt">integer</span>           <span class="kd">::</span> <span class="nb">long</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span>
<span class="kt">real</span>              <span class="kd">::</span> <span class="n">y</span>
<span class="kt">real</span>              <span class="kd">::</span> <span class="n">mult</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>  <span class="kd">::</span> <span class="n">ch</span>
<span class="kt">real</span><span class="p">,</span><span class="k">parameter</span>    <span class="kd">::</span> <span class="n">XMAXREAL</span><span class="o">=</span><span class="kt">real</span><span class="p">(</span><span class="nb">huge</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="kt">integer</span>           <span class="kd">::</span> <span class="n">out_sign</span>
<span class="kt">integer</span>           <span class="kd">::</span> <span class="n">basein_local</span>
<span class="kt">integer</span>           <span class="kd">::</span> <span class="n">ipound</span>
<span class="kt">integer</span>           <span class="kd">::</span> <span class="n">ierr</span>

  <span class="n">string_local</span><span class="o">=</span><span class="n">upper</span><span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">string</span><span class="p">)))</span>
  <span class="n">decodebase</span><span class="o">=</span><span class="p">.</span><span class="n">false</span><span class="p">.</span>

  <span class="n">ipound</span><span class="o">=</span><span class="nb">index</span><span class="p">(</span><span class="n">string_local</span><span class="p">,</span><span class="s1">&#39;#&#39;</span><span class="p">)</span>                                       <span class="c">! determine if in form [-]base#whole</span>
  <span class="k">if</span><span class="p">(</span><span class="n">basein</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mf">0.</span><span class="nb">and</span><span class="p">.</span><span class="n">ipound</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="mi">1</span><span class="p">)</span><span class="k">then</span>                                  <span class="c">! split string into two values</span>
     <span class="k">call </span><span class="n">string_to_value</span><span class="p">(</span><span class="n">string_local</span><span class="p">(:</span><span class="n">ipound</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span><span class="n">basein_local</span><span class="p">,</span><span class="n">ierr</span><span class="p">)</span>   <span class="c">! get the decimal value of the base</span>
     <span class="n">string_local</span><span class="o">=</span><span class="n">string_local</span><span class="p">(</span><span class="n">ipound</span><span class="o">+</span><span class="mi">1</span><span class="p">:)</span>                              <span class="c">! now that base is known make string just the value</span>
     <span class="k">if</span><span class="p">(</span><span class="n">basein_local</span><span class="p">.</span><span class="n">ge</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>                                         <span class="c">! allow for a negative sign prefix</span>
        <span class="n">out_sign</span><span class="o">=</span><span class="mi">1</span>
     <span class="k">else</span>
<span class="k">        </span><span class="n">out_sign</span><span class="o">=-</span><span class="mi">1</span>
     <span class="k">endif</span>
<span class="k">     </span><span class="n">basein_local</span><span class="o">=</span><span class="nb">abs</span><span class="p">(</span><span class="n">basein_local</span><span class="p">)</span>
  <span class="k">else</span>                                                                 <span class="c">! assume string is a simple positive value</span>
     <span class="n">basein_local</span><span class="o">=</span><span class="nb">abs</span><span class="p">(</span><span class="n">basein</span><span class="p">)</span>
     <span class="n">out_sign</span><span class="o">=</span><span class="mi">1</span>
  <span class="k">endif</span>

<span class="k">  </span><span class="n">out_baseten</span><span class="o">=</span><span class="mi">0</span>
  <span class="n">y</span><span class="o">=</span><span class="mf">0.0</span>
  <span class="k">ALL</span><span class="p">:</span> <span class="k">if</span><span class="p">(</span><span class="n">basein_local</span><span class="o">&lt;</span><span class="mf">2.</span><span class="nb">or</span><span class="p">.</span><span class="n">basein_local</span><span class="o">&gt;</span><span class="mi">36</span><span class="p">)</span> <span class="k">then</span>
<span class="k">    print</span> <span class="o">*</span><span class="p">,</span><span class="s1">&#39;(*decodebase* ERROR: Base must be between 2 and 36. base=&#39;</span><span class="p">,</span><span class="n">basein_local</span>
  <span class="k">else ALL</span>
<span class="k">     </span><span class="n">out_baseten</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="n">y</span><span class="o">=</span><span class="mf">0.0</span><span class="p">;</span> <span class="n">mult</span><span class="o">=</span><span class="mf">1.0</span>
     <span class="nb">long</span><span class="o">=</span><span class="nb">LEN_TRIM</span><span class="p">(</span><span class="n">string_local</span><span class="p">)</span>
     <span class="k">do </span><span class="n">i</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">long</span>
<span class="nb">        </span><span class="n">k</span><span class="o">=</span><span class="nb">long</span><span class="o">+</span><span class="mi">1</span><span class="o">-</span><span class="n">i</span>
        <span class="n">ch</span><span class="o">=</span><span class="n">string_local</span><span class="p">(</span><span class="n">k</span><span class="p">:</span><span class="n">k</span><span class="p">)</span>
        <span class="k">if</span><span class="p">(</span><span class="n">ch</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="s1">&#39;-&#39;</span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="n">k</span><span class="p">.</span><span class="n">eq</span><span class="p">.</span><span class="mi">1</span><span class="p">)</span><span class="k">then</span>
<span class="k">           </span><span class="n">out_sign</span><span class="o">=-</span><span class="mi">1</span>
           <span class="k">cycle</span>
<span class="k">        endif</span>
<span class="k">        if</span><span class="p">(</span><span class="n">ch</span><span class="o">&lt;</span><span class="s1">&#39;0&#39;</span><span class="p">.</span><span class="nb">or</span><span class="p">.</span><span class="n">ch</span><span class="o">&gt;</span><span class="s1">&#39;Z&#39;</span><span class="p">.</span><span class="nb">or</span><span class="p">.(</span><span class="n">ch</span><span class="o">&gt;</span><span class="s1">&#39;9&#39;</span><span class="p">.</span><span class="nb">and</span><span class="p">.</span><span class="n">ch</span><span class="o">&lt;</span><span class="s1">&#39;A&#39;</span><span class="p">))</span><span class="k">then</span>
<span class="k">           write</span><span class="p">(</span><span class="o">*</span><span class="p">,</span><span class="o">*</span><span class="p">)</span><span class="s1">&#39;*decodebase* ERROR: invalid character &#39;</span><span class="p">,</span><span class="n">ch</span>
           <span class="k">exit ALL</span>
<span class="k">        endif</span>
<span class="k">        if</span><span class="p">(</span><span class="n">ch</span><span class="o">&lt;=</span><span class="s1">&#39;9&#39;</span><span class="p">)</span> <span class="k">then</span>
<span class="k">              </span><span class="n">j</span><span class="o">=</span><span class="nb">IACHAR</span><span class="p">(</span><span class="n">ch</span><span class="p">)</span><span class="o">-</span><span class="nb">IACHAR</span><span class="p">(</span><span class="s1">&#39;0&#39;</span><span class="p">)</span>
        <span class="k">else</span>
<span class="k">              </span><span class="n">j</span><span class="o">=</span><span class="nb">IACHAR</span><span class="p">(</span><span class="n">ch</span><span class="p">)</span><span class="o">-</span><span class="nb">IACHAR</span><span class="p">(</span><span class="s1">&#39;A&#39;</span><span class="p">)</span><span class="o">+</span><span class="mi">10</span>
        <span class="k">endif</span>
<span class="k">        if</span><span class="p">(</span><span class="n">j</span><span class="o">&gt;=</span><span class="n">basein_local</span><span class="p">)</span><span class="k">then</span>
<span class="k">           exit ALL</span>
<span class="k">        endif</span>
<span class="k">        </span><span class="n">y</span><span class="o">=</span><span class="n">y</span><span class="o">+</span><span class="n">mult</span><span class="o">*</span><span class="n">j</span>
        <span class="k">if</span><span class="p">(</span><span class="n">mult</span><span class="o">&gt;</span><span class="n">XMAXREAL</span><span class="o">/</span><span class="n">basein_local</span><span class="p">)</span><span class="k">then</span>
<span class="k">           exit ALL</span>
<span class="k">        endif</span>
<span class="k">        </span><span class="n">mult</span><span class="o">=</span><span class="n">mult</span><span class="o">*</span><span class="n">basein_local</span>
     <span class="k">enddo</span>
<span class="k">     </span><span class="n">decodebase</span><span class="o">=</span><span class="p">.</span><span class="n">true</span><span class="p">.</span>
     <span class="n">out_baseten</span><span class="o">=</span><span class="nb">nint</span><span class="p">(</span><span class="n">out_sign</span><span class="o">*</span><span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="nb">sign</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">basein</span><span class="p">)</span>
  <span class="k">endif ALL</span>
<span class="k">end function </span><span class="n">decodebase</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>